import { createI18n } from 'vue-i18n';
import cache from "@/plugins/cache.js";
import ar from './lang/af.json';
import af from './lang/af.json';
import de from './lang/de.json';
import el from './lang/el.json';
import en from './lang/en.json';
import es from './lang/es.json';
import fr from './lang/fr.json';
import hi from './lang/hi.json';
import id from './lang/id.json';
import it from './lang/it.json';
import ja from './lang/ja.json';
import ko from './lang/ko.json';
import ms from './lang/ms.json';
import ph from './lang/ph.json';
import pt from './lang/pt.json';
import ru from './lang/ru.json';
import th from './lang/th.json';
import tr from './lang/tr.json';
import tw from './lang/tw.json';
import vi from './lang/vi.json';
import zh from './lang/zh.json';



const messages = {
  af,
  ar,
  de,
  el,
  en,
  es,
  fr,
  hi,
  id,
  it,
  ja,
  ko,
  ms,
  ph,
  pt,
  ru,
  th,
  tr,
  tw,
  vi,
  zh
};

const locale = cache.local.get('Coupon-Lang') || 'zh';

const i18n = createI18n({
  locale: locale, // 默认语言
  fallbackLocale: locale, // 回退语言
  globalInjection: true, // 全局注入,可以直接使用$t
  allowComposition: true,
  legacy: false,
  messages,
});

export default i18n;
